<?php

namespace App\Http\Controllers\Admin\Editor;
use App\Http\Requests\ArticlesPostRequest;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CommentController extends Controller
{
    public function getIndex()
    {
        
        $comment = DB::table('hs_comment')
            // ->join('hs_member',['hs_member.id'=>'hs_comment.publish_id','hs_comment.id'=>'hs_comment.reply_id'])
            ->join('hs_member','hs_member.id','=','hs_comment.publish_id')
            ->join('hs_articles','hs_comment.artid','=','hs_articles.id')
            ->join('hs_books','hs_articles.bid','=','hs_books.id')
            // ->where('hs_comment.status','=',0)
            ->where(['hs_comment.status' => 2,'hs_articles.aid'=>1])
            ->select('hs_comment.com_content','hs_member.name','hs_articles.title','hs_books.b_name','hs_comment.id','hs_comment.publish_id')
            ->get();


        // $comments = DB::table('hs_comment')->where('status','=',2)->get();
        // dd($comment);
        return view('admin.editor.comment.index',['comment'=>$comment]);
    }

    public function getRestore($id)
    {
        // dd($id);
        $res = DB::table('hs_comment')->where('id',$id)->update(['status'=>0]);
        if($res){
            return redirect('/admin/ecomment/index')->with('success','恢复成功');
        }
    }

     public function getDelete($id)
    {
        // dd($id);
        $res = DB::table('hs_comment')->where('id',$id)->delete();
        if($res){
            return redirect('/admin/ecomment/index')->with('success','删除成功');
        }
    }
}
